<template>
	<view class="green-action-page">
		<!-- 用户信息区域 -->
		<view class="user-info">
			<!-- 使用原生image组件替代u-avatar -->
			<image src="@/static/images/logo.png" mode="aspectFill" class="user-avatar"></image>
			<view class="user-info-right">
				<view class="username">小小杰</view>
				<view class="motto">奉献 环保 绿色 文明</view>
			</view>
			<view class="code-icons">
				<image src="@/static/images/code.png" mode="aspectFill" class="erweima"></image>
				<image src="@/static/images/scan.png" mode="aspectFill" class="saomiao"></image>
			</view>
		</view>

		<!-- 活动推荐区域 -->
		<view class="activity-section">
			<view class="section-header">
				<view class="section-title">活动推荐</view>
				<view class="see-all" @click="onSeeAll">查看全部></view>
			</view>
			<view class="activity-list">
				<view class="activity-item" v-for="(item, index) in activityList" :key="index">
					<text class="tag">{{ item.tag }}</text>
					<text class="region">{{ item.region }}</text>
					<view class="desc">{{ item.desc }}</view>
					<view class="address">{{ item.address }}</view>
					<view class="time-info">
						<view>{{ item.time }}</view>
						<view class="ml-10">剩余名额 {{ item.quota }}</view>
					</view>
				</view>
			</view>
			<!-- 自动匹配按钮 -->
			<button class="match-btn">自动匹配</button>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';

	const activityList = ref([{
			tag: '社区服务',
			region: '天河区',
			desc: '清理特定区域的垃圾（公园、河岸、海滩），提升环境整洁度，宣传垃圾不落地和垃圾分类意识。',
			address: '天河区某某公园',
			time: '2025/03/26 22:00 - 23:00',
			quota: 3
		},
		{
			tag: '社区服务',
			region: '天河区',
			desc: '推广废物利用理念，减少垃圾产生，激发创造力，赋予旧物新生命。',
			address: '天河区某某公园',
			time: '2025/03/26 22:00 - 23:00',
			quota: 3
		}
	]);

	const onBack = () => {
		uni.navigateBack();
	};

	const onSeeAll = () => {
		console.log('查看全部');
	};
</script>

<style scoped>
	.green-action-page {
		height: 30vh;
		background: linear-gradient(#C8E6C9, #fff);
		padding: 20rpx;
		box-sizing: border-box;
	}

	/* 用户信息 */
	.user-info {
		display: flex;
		align-items: center;
		padding: 30rpx 0;
	}

	/* 自定义头像样式 */
	.user-avatar {
		width: 80rpx;
		/* 对应u-avatar的size=50（50px=100rpx） */
		height: 80rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 20rpx;
		border: 2rpx solid #fff;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
		object-fit: cover;
		/* 确保图片填满容器 */
	}

	.user-info-right {
		display: flex;
		flex-direction: column;
	}

	.username {
		font-size: 40rpx;
		font-weight: bold;
		color: #000;
	}

	.motto {
		font-size: 30rpx;
		color: #666;
	}

	.code-icons {
		display: flex;
		gap: 20rpx;
	}

	.erweima {
		width: 80rpx;
		height: 80rpx;
		margin-left: 160rpx;
	}

	.saomiao {
		border-radius: 20rpx;
		width: 80rpx;
		height: 80rpx;
	}

	/* 活动推荐区域 */
	.activity-section {
		/* margin-top: 60rpx; */
		position: absolute;
		top: 400rpx;
	}

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10rpx;
	}

	.section-title {
		font-size: 44rpx;
		font-weight: bold;
		color: #000;
	}

	.see-all {
		font-size: 26rpx;
		color: #666;
		margin-right: 12rpx;
	}

	.activity-list {
		padding: 0 20rpx;
	}

	.activity-item {
		border-radius: 16rpx;
		padding: 20rpx;
		margin-top: 20rpx;
		margin-bottom: 50rpx;
		box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.25);
	}

	.tag {
		color: #ff6b6b;
		font-size: 28rpx;
		margin-right: 24rpx;
	}

	.region {
		font-size: 28rpx;
		color: #000;
		margin: 10rpx 0;
	}

	.desc {
		font-size: 28rpx;
		color: #000;
		line-height: 1.4;
		margin-top: 8rpx;
	}

	.address {
		font-size: 28rpx;
		color: #999;
		margin-top: 12rpx;
	}

	.time-info {
		font-size: 28rpx;
		color: #999;
		display: flex;
		align-items: center;
	}

	/* 自动匹配按钮 */
	.match-btn {
		background-color: #ffd166;
		color: #fff;
		font-size: 32rpx;
		border-radius: 50rpx;
		width: 60%;
		margin: 60rpx auto 0;
		display: block;
		box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.2);
	}

	.ml-10 {
		margin-left: 100rpx;
	}
</style>